<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="姓名" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="证件号" prop="cardnumber">
        <el-input
          v-model="queryParams.cardnumber"
          placeholder="请输入证件号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="状态" prop="type">
        <el-select v-model="queryParams.type" clearable placeholder="请选择">
          <el-option
            v-for="item in typelist"
            :key="item.value"
            :label="item.name"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <!-- <el-button
          type="primary"
          plain
          icon="el-icon-refresh"
          size="mini"
          @click="handleAdd"
          >同步</el-button
        > -->
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="caseareaList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="姓名" align="center" prop="name" />
      <el-table-column label="证件号" align="center" prop="cardnumber" />
      <el-table-column label="联系电话" align="center" prop="phone" />
      <el-table-column label="性别" align="center" prop="gender" />
      <el-table-column label="年龄" align="center" prop="age" />
      <el-table-column label="出生日期" align="center" prop="birthdate" />
      <el-table-column label="入区是否已同步" align="center" prop="ypeople">
        <template
          slot-scope="scope"
        >
          <el-tag
            effect="dark"
            :type="scope.row.ypeople != null ? 'success' : 'danger'"
            close-transition
            >{{ scope.row.ypeople != null ? "是" : "否" }}</el-tag
          >
        </template>
      </el-table-column>
      <el-table-column label="出区是否已同步" align="center" prop="ypeople">
        <template
          slot-scope="scope"
          :type="(scope.row.ypeople != null&&scope.row.outareatime!=null && scope.row.zfoutareatime!=null) ? 'success' : 'danger'"
        >
          <el-tag
            effect="dark"
            v-if="(scope.row.ypeople != null&&scope.row.outareatime!=null)"
            :type="(scope.row.ypeople != null&&scope.row.outareatime!=null && scope.row.zfoutareatime!=null) ? 'success' : 'danger'"
            close-transition
            >{{ (scope.row.ypeople != null&&scope.row.outareatime!=null && scope.row.zfoutareatime!=null)  ? "是" : "否" }}</el-tag
          >
        </template>
      </el-table-column>
      <!-- <el-table-column label="操作">
        <template slot-scope="scope" v-if="scope.row.ypeople == null">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:user:edit']"
            >同步</el-button
          >
        </template>
      </el-table-column> -->
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import {
  listCasearea,
  getCasearea,
  delCasearea,
  addCasearea,
  updateCasearea,
} from "@/api/business/casearea";

export default {
  name: "Casearea",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 入区人员信息明细表格数据
      caseareaList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        name: null,
        cardnumber: null,
        type: null,
      },
      typelist: [
        { name: "已同步", value: "1" },
        { name: "未同步", value: "0" },
      ],
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        centerinfoid: [
          { required: true, message: "办案中心Id不能为空", trigger: "blur" },
        ],
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询入区人员信息明细列表 */
    getList() {
      this.loading = true;
      listCasearea(this.queryParams).then((response) => {
        console.log(response);
        this.caseareaList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.fId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
    },
  },
};
</script>
